package com.shsoft.config;


import com.shsoft.MonitorApplication;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

public class SettingConfig {

    private String theme;

    private boolean systemTray;

    private boolean autoStart;

    private boolean autoLight;

    private int light;

    private String key;

    private String cityName;

    private String cityID;

    private String port;

    private String templateName;

    public void initConfigs(){
        String projectPath = System.getProperty("user.dir");
        MonitorApplication.projectPath = projectPath;
        Properties properties = new Properties();
        InputStreamReader reader = null;
        try {
            reader = new InputStreamReader(new FileInputStream(projectPath + "\\config\\config.properties"), "utf-8");
            properties.load(reader);
            this.theme = properties.getProperty("theme");
            this.systemTray = Boolean.parseBoolean(properties.getProperty("systemTray"));
            this.autoStart = Boolean.parseBoolean(properties.getProperty("autoStart"));
            this.autoLight = Boolean.parseBoolean(properties.getProperty("autoLight"));
            this.light = Integer.parseInt(properties.getProperty("light"));
            this.templateName = properties.getProperty("templateName");
            this.port = properties.getProperty("port");
            this.key = properties.getProperty("key");
            this.cityName = properties.getProperty("cityName");
            this.cityID = properties.getProperty("cityID");
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }

    public boolean isAutoLight() {
        return autoLight;
    }

    public void setAutoLight(boolean autoLight) {
        this.autoLight = autoLight;
    }

    public int getLight() {
        return light;
    }

    public void setLight(int light) {
        this.light = light;
    }

    public String getTemplateName() {
        return templateName;
    }

    public void setTemplateName(String templateName) {
        this.templateName = templateName;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getCityID() {
        return cityID;
    }

    public void setCityID(String cityID) {
        this.cityID = cityID;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getTheme() {
        return theme;
    }

    public void setTheme(String theme) {
        this.theme = theme;
    }

    public boolean isSystemTray() {
        return systemTray;
    }

    public void setSystemTray(boolean systemTray) {
        this.systemTray = systemTray;
    }

    public boolean isAutoStart() {
        return autoStart;
    }

    public void setAutoStart(boolean autoStart) {
        this.autoStart = autoStart;
    }
}
